import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) {
        Dog dog1 = new Dog(6,"xiaohei");
        Dog dog2 = new Dog(7,"xiaobai");
        Dog dog3 = new Dog(5,"xiaodog");
        Dog dog4 = new Dog(8,"wangcai");
        Dog[] dogs = new Dog[]{dog1,dog2,dog3,dog4};

        NameComparator nameComparator = new NameComparator();
        Arrays.sort(dogs,nameComparator);

        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i].toString());

        }
    }

    public static void main2(String[] args) {
        Dog dog1 = new Dog(6,"xiaohei");
        Dog dog2 = new Dog(7,"xiaobai");
        Dog dog3 = new Dog(5,"xiaodog");
        Dog dog4 = new Dog(8,"wangcai");
        Dog[] dogs = new Dog[]{dog1,dog2,dog3,dog4};

        Arrays.sort(dogs);

        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i].toString());

        }
    }
    public static void main1(String[] args) {
        Dog dog1 = new Dog(6,"xiaohei");
        Dog dog2 = new Dog(7,"xiaobai");
        System.out.println(dog1 .compareTo(dog2));
    }
}